// house_pkg/pages/room/index.ts
Page({

  /**
   * 页面的初始数据
   */
  data: {

  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad({
    point,
    building
  }) {
    console.log(point, building)
    this.mock(point, building)
  },
  // 伪造房间
  mock(point, building) {
    const size = Math.floor(Math.random() * 5) + 4
    // 定义数组保存房间号
    const rooms = []
    for (let i = 0; i < size; i++) {
      // 楼层号
      const floor = Math.floor(Math.random() * 20) + 1
      // 房间号
      const no = Math.floor(Math.random() * 4) + 1
      // 组合楼层+房间号  1803
      const room = `${floor}0${no}`
      // console.log(room)
      if (rooms.includes(room)) continue
      rooms.push(room)
    }
    // 将 小区名称 多少栋 房间号保存到 data里面
    this.setData({
      point: point,
      building: building,
      rooms: rooms
    })
  }

})